// Basic types needed for stores

export interface HistoryVersion {
  id: string
  timestamp: number
  fileCount: number
  hasEntriesFile: boolean
}

export interface FileEntry {
  id: string
  source?: string
  timestamp: number
}

export interface VersionEntries {
  version: number
  resource: string
  entries: FileEntry[]
}

export interface FileTreeNode {
  id: string
  name: string
  path: string
  type: 'file' | 'folder'
  size?: number
  timestamp?: number
  children?: FileTreeNode[]
  isExpanded?: boolean
}

export interface FileHistoryRecord {
  versionId: string
  fileId: string
  originalPath: string
  timestamp: number
  source?: string
  size: number
  exists: boolean
}

export interface SearchOptions {
  caseSensitive: boolean
  exactMatch: boolean
  fileTypes: string[]
  versionIds: string[]
  maxResults: number
}

export interface ContentSearchOptions extends SearchOptions {
  contextLines: number
  regex: boolean
}

export interface SearchResult {
  versionId: string
  fileId: string
  originalPath: string
  fileName: string
  timestamp: number
  matchScore: number
}

export interface ContentMatch {
  lineNumber: number
  lineContent: string
  matchStart: number
  matchEnd: number
  context: string[]
}

export interface ContentSearchResult extends SearchResult {
  matches: ContentMatch[]
}

export interface SearchCriteria {
  fileName?: string
  content?: string
  fileType?: string
  dateRange?: DateRange
  sizeRange?: SizeRange
  versionIds?: string[]
}

export interface DateRange {
  start: Date
  end: Date
}

export interface SizeRange {
  min: number
  max: number
}

export interface RecoveryTask {
  versionId: string
  fileId: string
  originalPath: string
  targetPath: string
}

export interface RecoveryOptions {
  overwrite: boolean
  createDirectories: boolean
  preserveTimestamp: boolean
}

export interface BatchRecoveryOptions extends RecoveryOptions {
  continueOnError: boolean
  maxConcurrent: number
}

export interface RecoveryResult {
  success: boolean
  targetPath: string
  error?: string
  bytesWritten: number
}

export interface BatchRecoveryResult {
  successful: RecoveryResult[]
  failed: RecoveryResult[]
  totalCount: number
  duration: number
}

export interface ConflictInfo {
  targetPath: string
  existingFile: boolean
  sizeConflict: boolean
}

export interface RecoveryPreview {
  tasks: RecoveryTask[]
  conflicts: ConflictInfo[]
  totalSize: number
  estimatedDuration: number
}

// Diff viewer types
export interface FileReference {
  versionId: string
  fileId: string
  path: string
  content: string
  timestamp: number
}

export interface DiffResult {
  additions: number
  deletions: number
  modifications: number
  chunks: DiffChunk[]
}

export interface DiffChunk {
  type: 'add' | 'delete' | 'modify' | 'context'
  oldStart: number
  oldLines: number
  newStart: number
  newLines: number
  lines: DiffLine[]
}

export interface DiffLine {
  type: 'add' | 'delete' | 'context'
  oldNumber?: number
  newNumber?: number
  content: string
}

export interface DiffViewState {
  leftFile: FileReference | null
  rightFile: FileReference | null
  diffResult: DiffResult | null
  viewMode: 'side-by-side' | 'inline'
}